package cn.boltzjf.sql4j.examples.mysql.dao;

import static cn.boltzjf.sql4j.coltype.DefaultColumnTypes.UUID;

import java.sql.Connection;
import java.util.UUID;

import cn.boltzjf.sql4j.dao.Dao;
import cn.boltzjf.sql4j.dao.ValueConverter;
import cn.boltzjf.sql4j.ext.mysql.MysqlTypeUtils;

public abstract class BaseDao extends Dao {

    static {
        MysqlTypeUtils.VALUE_CONVERTER.registerDbValueReader(UUID, (s, t) -> {return byte[].class.isInstance(s) ? MysqlTypeUtils.binToUuid((byte[])s) : s;});
        MysqlTypeUtils.VALUE_CONVERTER.registerDbValueWriter(UUID, (s, t) -> {return UUID.class.isInstance(s) ? MysqlTypeUtils.uuidToBin((UUID)s) : s;});
    }
    
    @Override
    protected ValueConverter valueConverter() {
        return MysqlTypeUtils.VALUE_CONVERTER;
    }

    @Override
    protected Connection getConnection() {
        return null;
    }

}
